from time import sleep
from base.base import Base
import page


class PageLogin(Base):
    # 点击登录链接
    def page_click_login_link(self):
        self.base_click(page.login_url)

    # 输入用户名
    def page_input_username(self, username):
        self.base_input(page.login_username, username)

    # 输入密码
    def page_input_password(self, password):
        self.base_input(page.login_password, password)

    # 输入验证码
    def page_input_verify(self, verify_code):
        self.base_input(page.login_verify, verify_code)

    # 点击登录按钮
    def page_click_login_btn(self):
        self.base_click(page.login_btn)

    # 获取提示信息
    def page_get_info(self):
        return self.base_get_info(page.verify_info)

    # 点击提示信息确认按钮
    def page_click_info_btn(self):
        self.base_click(page.verify_info_check_btn)

    # 截图方法
    def page_get_screenshot(self):
        self.base_get_screenshot()

    # 集成方法
    def page_login(self, username, password, verify_code):
        self.page_input_username(username)
        self.page_input_password(password)
        self.page_input_verify(verify_code)
        self.page_click_login_btn()
        sleep(1)    # 必须延时一秒才能捕获到提示框信息
